Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

36
LINES

< > BotCompany Repo | #1011725 // websMadeByProgram_parallel_buggy - await() problem

JavaX fragment (include)

1  
static L<Web> websMadeByProgram_parallel_buggy(S progID) ctex {
2  
  // TODO: clean up file handle in case of error
3  
  IterableIterator<S> l = scanLog_iterator(progID, "webs-made.txt");
4  
  fS src = progID;
5  
  final new L<Pair<Web, Int>> webs;
6  
  
7  
  int poolSize = numberOfCores(), queueSize = 20;
8  
  NotifyingBlockingThreadPoolExecutor e = new(poolSize, queueSize, 15, TimeUnit.SECONDS);
9  
  
10  
  try {
11  
    int i = 0;
12  
    for (fS s : l) {
13  
      ++i;
14  
      final int _i = i;
15  
      e.execute(r { pcall {
16  
        SoftwareMadeWeb o = cast unstructure(s);
17  
        Web web = o.web;
18  
        if (web == null)
19  
          web = (Web) unstructure(o.structure);
20  
        if (web != null) synchronized(webs) {
21  
          webs.add(pair(web_intern(web_setSourceIfEmpty(web, src)), _i));
22  
        }
23  
      }});
24  
    }
25  
    e.await(); // ConcurrentModificationException sometimes??
26  
    //e.shutdown();
27  
    //e.awaitTermination(1, TimeUnit.DAYS);
28  
  } finally {
29  
    e.shutdown();
30  
  }
31  
  
32  
  time "Sort" {
33  
    sortBySecondOfPairs_inPlace(webs);
34  
  }
35  
  ret firstOfPairs(webs);
36  
}

Author comment

Began life as a copy of #1011722

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1011725
Snippet name: websMadeByProgram_parallel_buggy - await() problem
Eternal ID of this version: #1011725/1
Text MD5: 521ddcc70b4cdca1ab0e817e01817b1c
Author: stefan
Category: javax / a.i.
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-11-03 16:38:01
Source code size: 1070 bytes / 36 lines
Pitched / IR pitched: No / No
Views / Downloads: 356 / 390
Referenced in: [show references]